package com.example.littleSpider.myapplication.fragment.findPartner;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.View;
import android.widget.FrameLayout;

import com.example.littleSpider.myapplication.R;
import com.example.littleSpider.myapplication.base.BaseFragment;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by littleSpider on 2018/1/16.
 */

public class GuapoFragment extends BaseFragment {

    @BindView(R.id.fragment)
    FrameLayout fragment;

    private FragmentManager manager;
    Fragment fragmentAll, fragmentBeautifulGirl;

    @Override
    protected int setLayout() {
        return R.layout.fragment_guapo;
    }

    @Override
    protected void initView() {
        fragmentAll = new AllOfPartnerFragment();
        fragmentBeautifulGirl = new BeautifulGirlFragment();
        manager = getFragmentManager();
        FragmentTransaction transaction = manager.beginTransaction();
        transaction.add(R.id.fragment, new AllOfPartnerFragment());
        transaction.commit();
    }

    @Override
    protected void initData() {

    }

    @OnClick({R.id.btn_all, R.id.btn_beautiful_girl, R.id.btn_handsome_boy})
    public void choose(View view){
        FragmentTransaction transaction = manager.beginTransaction();
//                transaction.hide(fragmentAll);
//                transaction.hide(fragmentBeautifulGirl);
        int chooseNum;
        switch (view.getId()){
            case R.id.btn_all:
                Log.i("littleKiss", "I'm Bond.");
                transaction.replace(R.id.fragment, new AllOfPartnerFragment());
//                if (fragmentAll.isAdded()){
//                    transaction.show(fragmentAll);
//                }
                chooseNum = 0;
                break;
            case R.id.btn_beautiful_girl:
//                if (fragmentBeautifulGirl.isAdded()){
//                    transaction.show(fragmentBeautifulGirl);
//                }else {
//                    transaction.add(R.id.fragment, fragmentBeautifulGirl);
//                    transaction.show(fragmentBeautifulGirl);
//                }
                transaction.replace(R.id.fragment, new BeautifulGirlFragment());
                chooseNum = 1;
                break;
            case R.id.btn_handsome_boy:
                chooseNum = 2;
                break;
            default:
                chooseNum = 0;
                break;
        }
        transaction.commit();
    }
}
